package www.yingdi365.com.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import www.yingdi365.com.R;
import www.yingdi365.com.base.ZjbBaseActivity;
import www.yingdi365.com.constant.Constant;
import www.yingdi365.com.util.DpUtils;
import www.yingdi365.com.util.ScreenUtils;

public class HeKaYLActivity extends ZjbBaseActivity implements View.OnClickListener {

    private ImageView imageBg;
    private String url;
    private String title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_he_ka_yl);
        init();
    }

    @Override
    protected void initSP() {

    }

    @Override
    protected void initIntent() {
        Intent intent = getIntent();
        url = intent.getStringExtra(Constant.INTENT_KEY.URL);
        title = intent.getStringExtra(Constant.INTENT_KEY.TITLE);
    }

    @Override
    protected void findID() {
        imageBg = (ImageView) findViewById(R.id.imageBg);
    }

    @Override
    protected void initViews() {
        ((TextView)findViewById(R.id.textViewTitle)).setText(title);
        ViewGroup.LayoutParams layoutParams = imageBg.getLayoutParams();
        int screenWidth = ScreenUtils.getScreenWidth(this);
        float width = screenWidth - DpUtils.convertDpToPixel(20f, this);
        float height = width * 1.4375f;//height is ready
        layoutParams.width = (int) width;
        layoutParams.height = (int) height;
        imageBg.setLayoutParams(layoutParams);
        Glide.with(HeKaYLActivity.this)
                .load(url)
                .placeholder(R.mipmap.ic_empty)
                .into(imageBg);
    }

    @Override
    protected void setListeners() {
        findViewById(R.id.imageBack).setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.imageBack:
                finish();
                break;
        }
    }
}
